/* 管理后台基础样式 */
:root {
    --admin-primary: #4f46e5;
    --admin-primary-dark: #4338ca;
    --admin-success: #10b981;
    --admin-warning: #f59e0b;
    --admin-danger: #ef4444;
    --admin-bg: #f3f4f6;
    --admin-card: #ffffff;
    --admin-text: #111827;
    --admin-text-light: #6b7280;
    --admin-border: #e5e7eb;
    --admin-sidebar-width: 280px;
    --admin-header-height: 64px;
    --admin-shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --admin-radius: 8px;
    --admin-transition: cubic-bezier(0.4, 0, 0.2, 1);
}

/* 深色主题 */
@media (prefers-color-scheme: dark) {
    :root {
        --admin-bg: #1f2937;
        --admin-card: #111827;
        --admin-text: #f9fafb;
        --admin-text-light: #9ca3af;
        --admin-border: #374151;
    }
}

/* 基础样式 */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: system-ui, -apple-system, sans-serif;
    background: var(--admin-bg);
    color: var(--admin-text);
    line-height: 1.5;
    overflow-x: hidden;
    position: relative;
}

/* 防止页面弹跳和缩放 */
.prevent-bounce {
    position: fixed;
    width: 100%;
    height: 100%;
    overflow: hidden;
    overscroll-behavior: none;
    -webkit-overflow-scrolling: touch;
}

/* 布局容器 */
.admin-container {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    overflow: hidden;
}

/* 遮罩层 */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 35;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s var(--admin-transition);
}

.sidebar-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* 侧边栏 */
.admin-sidebar {
    width: var(--admin-sidebar-width);
    background: var(--admin-card);
    border-right: 1px solid var(--admin-border);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    bottom: 0;
    z-index: 40;
    transition: transform 0.3s var(--admin-transition);
}

/* 侧边栏头部 */
.sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--admin-border);
    background: var(--admin-card);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--admin-primary);
}

.logo i {
    font-size: 1.5rem;
}

/* 导航菜单 */
.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
    overflow-y: auto;
    background: var(--admin-card);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1.5rem;
    color: var(--admin-text-light);
    text-decoration: none;
    transition: all 0.2s var(--admin-transition);
    border-left: 3px solid transparent;
}

.nav-item:hover,
.nav-item.active {
    color: var(--admin-primary);
    background: color-mix(in srgb, var(--admin-primary) 10%, transparent);
    border-left-color: var(--admin-primary);
}

.nav-item i {
    font-size: 1.25rem;
}

/* 主内容区 */
.admin-main {
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    left: var(--admin-sidebar-width);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
    transition: all 0.3s var(--admin-transition);
    padding: 1.5rem;
}

/* 顶部栏 */
.admin-header {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--admin-sidebar-width);
    height: var(--admin-header-height);
    background: var(--admin-card);
    border-bottom: 1px solid var(--admin-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    z-index: 30;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    transition: all 0.3s var(--admin-transition);
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 20px;
    background: transparent;
    color: var(--admin-text);
    cursor: pointer;
    font-size: 1.5rem;
}

.page-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--admin-text);
}

/* 数据库状态 */
.db-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--admin-bg);
    border-radius: var(--admin-radius);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 4px;
    background: var(--admin-text-light);
}

.status-dot.connected {
    background: var(--admin-success);
}

.status-dot.error {
    background: var(--admin-danger);
}

/* 内容区域 */
.content-section {
    display: none;
    animation: fadeIn 0.3s var(--admin-transition);
}

.content-section.active {
    display: block;
}

/* 统计卡片 */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    background: var(--admin-card);
    border-radius: var(--admin-radius);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--admin-shadow);
    transition: all 0.3s var(--admin-transition);
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 24px;
    background: color-mix(in srgb, var(--admin-primary) 15%, transparent);
    color: var(--admin-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.stat-info h3 {
    font-size: 0.875rem;
    color: var(--admin-text-light);
    margin-bottom: 0.25rem;
}

.stat-info p {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--admin-text);
}

/* 空状态 */
.empty-state {
    padding: 2rem;
    text-align: center;
    color: var(--admin-text-light);
    font-size: 0.875rem;
    background: var(--admin-bg);
    border-radius: var(--admin-radius);
    margin: 1rem 0;
}

.empty-state i {
    font-size: 2rem;
    margin-bottom: 1rem;
    color: var(--admin-text-light);
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--admin-bg);
}

::-webkit-scrollbar-thumb {
    background: var(--admin-border);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--admin-text-light);
}

/* 动画 */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 响应式设计 */
@media (max-width: 768px) {
    .admin-sidebar {
        transform: translateX(-100%);
        width: 100%;
        max-width: 280px;
    }

    .admin-sidebar.show {
        transform: translateX(0);
    }

    .admin-main {
        left: 0;
        width: 100%;
        padding: 1rem;
    }

    .admin-header {
        left: 0;
        width: 100%;
        padding: 0 1rem;
    }

    .menu-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    /* 移动端滑动菜单 */
    body.sidebar-open {
        overflow: hidden;
    }

    .admin-main.shifted {
        transform: translateX(280px);
    }

    .admin-header.shifted {
        transform: translateX(280px);
    }

    .stat-card {
        padding: 1rem;
    }

    .stat-icon {
        width: 40px;
        height: 40px;
        font-size: 1.25rem;
    }

    .stat-info p {
        font-size: 1.25rem;
    }

    .empty-state {
        padding: 1.5rem;
        font-size: 0.8125rem;
    }

    .empty-state i {
        font-size: 1.75rem;
    }
}